
{% extends "blog/base.html" %}

{% load static wagtailcore_tags wagtailimages_tags blogapp_tags el_pagination_tags wagtailmd %}

{% block content %}

    {% if search_term %}
      <header class="page-header">
          <h1 class="page-title">Search Results for <span>{{ search_type }}: {{ search_term }}</span></h1>
      </header>
    {% endif %}

    {% paginate 5 posts %}
    {% for post in posts %}
      <!-- Blog Post -->
      <div class="card mb-4">

        {% if post.header_image %}
            {% image post.header_image original as header_image %}
            <a href="{% post_date_url post blog_page %}">
              <img src="{{ header_image.url }}" class="card-img-top" ></img>
            </a>
        {% endif %}

        <div class="card-body">
          <h2 class="card-title">
            <a href="{% post_date_url post blog_page %}">{{ post.title }}</a>
          </h2>
          <p class="card-text">
            {% if post.excerpt %}
                {{ post.excerpt|markdown|safe }}
            {% else %}
                {{ post.body|markdown|safe|truncatewords_html:70 }}
            {% endif %}
          </p>
          <a href="{% post_date_url post blog_page %}" class="btn btn-primary">Read More &rarr;</a>

        </div>
        <div class="card-footer text-muted">
            Posted on {{ post.date }}
        </div>
      </div>

    {% endfor %}

    <!-- Pagination -->
    <ul class="pagination justify-content-center mb-4">
      {% show_pages %}
    </ul>

{% endblock %}